package com.xgq.drink.exception;

import com.xgq.drink.entity.R;
import com.xgq.drink.utils.RUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(RuntimeException.class)
    public R handleRuntimeException(RuntimeException e) {
        return RUtils.fail(e.getMessage());
    }

    @ExceptionHandler(UserNotFoundException.class)
    public R handleUserNotFoundException(UserNotFoundException e) {
        return RUtils.fail(e.getMessage());
    }

    @ExceptionHandler(InvalidPasswordException.class)
    public R handleInvalidPasswordException(InvalidPasswordException e) {
        return RUtils.fail(e.getMessage());
    }
} 